<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
          name="viewport">
    <link href="layuiadmin/layui/css/layui.css" media="all" rel="stylesheet">
    <link href="layuiadmin/style/admin.css" media="all" rel="stylesheet">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>增加商户</legend>
</fieldset>
<form action="" class="layui-form" id="myform">
    <div class="layui-form-item">
        <label class="layui-form-label">商户编码</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" lay-reqtext="商户编码为必填项" lay-verify="required" name="vendorCode"
                   placeholder="请输入" type="text">
        </div>
        <label class="layui-form-label">商户名称</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" lay-reqtext="商户名称为必填项" lay-verify="required" name="vendorName"
                   placeholder="请输入" type="text">
        </div>
        <label class="layui-form-label">主联系人</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" lay-reqtext="主联系人为必填项" lay-verify="required" name="personId"
                   placeholder="请输入" type="text">
        </div>
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" lay-reqtext="联系电话为必填项" lay-verify="required" name="phone"
                   placeholder="请输入" type="text">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">地址</label>
            <div class="layui-input-block">
                <input autocomplete="off" class="layui-input" lay-reqtext="联系电话为必填项" lay-verify="required"
                       name="address" placeholder="请输入" type="text">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开是否启用</label>
            <div class="layui-input-block">
                <input checked="" name="enabledFlag" title="启用" type="radio" value="Y">
                <input name="enabledFlag" title="不启用" type="radio" value="N">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" name="description" placeholder="请输入内容"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-filter="formDemo" lay-submit="" type="submit">立即提交</button>
                <button class="layui-btn layui-btn-primary" type="reset">重置</button>
            </div>
        </div>
    </div>
    <script src="layuiadmin/layui/layui.js"></script>
    <script>
        layui.use('form', function () {
            var form = layui.form;
            var $ = layui.$;
            form.on('submit(formDemo)', function (data) {
                console.log(JSON.stringify(data.field));
                $.ajax({
                    url: 'http://localhost:8086/insertVendor',
                    data: data.field,
                    type: "post",
                    dataType: "json",
                    async: 'false',
                    success: function (data) {
                        console.log(data);
                        window.parent.location.reload();
                        parent.layer.closeAll();
                    },
                    error: function (data) {
                        $.messager.alert('错误', data.msg);
                    }
                });
            })
            form.render();
        });
    </script>
</form>
</body>
</html>